using System;
using Game.Scripts.Constant;
using Game.Scripts.Entity.UI.NextGameMenu;
using UnityEngine;
using Zenject;

namespace Game.Scripts.Entity
{
    public class EndPoint : MonoBehaviour
    {
        private IkunBus _ikunBus;
        private NextGameMenu _nextGameMenu;
        
        [Inject]
        public void Construct(IkunBus ikunBus, NextGameMenu nextGameMenu)
        {
            _ikunBus = ikunBus;
            _nextGameMenu = nextGameMenu;
        }

        
        private void OnTriggerEnter(Collider other)
        {
            if (other.gameObject.CompareTag(TagType.Player))
            {
                _ikunBus.StopCountDown();
                // advance to next game level
                _ikunBus.PauseBusState();
                _nextGameMenu.Open(NextGameMenuOpenState.NextGame);
            }
        }
    }
}